#include "classdialog.h"
#include "ui_classdialog.h"

ClassDialog::ClassDialog(QWidget *parent)
    : QDialog(parent)
    , m_pCategoryInfo(nullptr)
    , ui(new Ui::ClassDialog)
{
    ui->setupUi(this);
}

ClassDialog::~ClassDialog()
{
    delete ui;
}

void ClassDialog::SetCategoryInfo(CategoryInfo* pCategoryInfo){
    m_pCategoryInfo = pCategoryInfo;
    ui->lineEditCategoryKey->setText(QString::number(pCategoryInfo->GetKey()));
    ui->lineEditCategoryName->setText(pCategoryInfo->GetName());
}

void ClassDialog::accept(){
    m_pCategoryInfo->SetName(ui->lineEditCategoryName->text());
    m_pCategoryInfo->SetKey(ui->lineEditCategoryKey->text().toInt());
    QDialog::accept();
}
